package com.ruoyi.web.controller.tourism;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HotelsOrder;
import com.ruoyi.system.service.IHotelsOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间订单Controller
 *
 * @author Y.C
 * @date 2024-02-21
 */
@RestController
@RequestMapping("/system/hotelsOrder")
public class HotelsOrderController extends BaseController
{
    @Autowired
    private IHotelsOrderService hotelsOrderService;

    /**
     * 查询房间订单列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(HotelsOrder hotelsOrder)
    {
        startPage();
        List<HotelsOrder> list = hotelsOrderService.selectHotelsOrderList(hotelsOrder);
        return getDataTable(list);
    }

    /**
     * 导出房间订单列表
     */
    @Anonymous

    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelsOrder hotelsOrder)
    {
        List<HotelsOrder> list = hotelsOrderService.selectHotelsOrderList(hotelsOrder);
        ExcelUtil<HotelsOrder> util = new ExcelUtil<HotelsOrder>(HotelsOrder.class);
        util.exportExcel(response, list, "房间订单数据");
    }

    /**
     * 获取房间订单详细信息
     */
    @Anonymous
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return success(hotelsOrderService.selectHotelsOrderByOrderId(orderId));
    }

    /**
     * 新增房间订单
     */
    @Anonymous

    @PostMapping
    public AjaxResult add(@RequestBody HotelsOrder hotelsOrder)
    {
        return toAjax(hotelsOrderService.save(hotelsOrder));
    }

    /**
     * 修改房间订单
     */
    @Anonymous

    @PutMapping
    public AjaxResult edit(@RequestBody HotelsOrder hotelsOrder)
    {
        return toAjax(hotelsOrderService.updateById(hotelsOrder));
    }

    /**
     * 删除房间订单
     */
    @Anonymous

	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(hotelsOrderService.removeByIds(Arrays.asList(orderIds)));
    }
}
